package study.alibaba.sentinel.controller._1_flow;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import study.alibaba.sentinel.support.handler.GlobalBlockHandler;
import study.eggs.result.Result;
import study.eggs.result.Results;

import java.util.Map;

@Slf4j
@RestController
public class _02_FlowController {

    @SentinelResource(value = "/flow2",
            blockHandlerClass = GlobalBlockHandler.class,
            blockHandler = "handlerException")
    @RequestMapping("/flow2")
    public Result echo() {
        Map<String, Object> data = Maps.newHashMap();
        data.put("msg", "flow1 flow1 flow1");
        return Results.ok(data);
    }
}
